package cn.learn.async.restful;

import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 模拟消息队列
 *
 * @author huangyezhan
 * @version 1.0
 * @date 2021年08月19日22:17
 */
@Slf4j
@Setter
@Getter
@Component
public class MockQueue {

    private String placeOrder;
    private String completeOrder;

    public void setPlaceOrder(String placeOrder) {
        new Thread(()->{
            log.info("接到下单请求{}", placeOrder);
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            this.completeOrder = placeOrder;
            log.info("下单请求处理完毕{}", placeOrder);
        }).start();
    }
}
